const notification = require('./notification.js');
const formutil={
  isRequired(value) {
    let ret = false;
    if (value != undefined && value != null && value != NaN && value != "") {
      ret = true;
      let vr = (value + "").replace(/\ /g, "")
      if (vr === "") {
        ret = false;
      }
    }
    if (value === "0" || value === 0 || value === "1" || value === 1) {
      ret = true;
    }
  
    if (value === false) {
      ret = true;
    }
    return ret;
  },
  isFormRequired(formdata, req) {
    for (var name in req) {
      if (!isRequired(formdata[name])) {
        notification.error(req[name]);
        return false;
      }
    }
    return true;
  }
}

module.exports = notification;